package com.gongj.jedis.fbsLock;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @program: jedis
 * @description:
 * @author: gongj
 * @Description: TODO
 * @create: 2020-07-11 18:05
 **/
public class Redis {

    private JedisPool jedisPool;

    public Redis(){
        JedisPoolConfig config = new JedisPoolConfig();
        // 最大连接数
        config.setMaxTotal(10);
        // 最大连接空闲数
        config.setMaxIdle(2);
         jedisPool = new JedisPool(config, "47.105.198.54", 6379,10000,"yj19980402");
    }

    public void execute(CallWithJedis callWithJedis){
        try(Jedis jedis = jedisPool.getResource()) {
            callWithJedis.call(jedis);
        }
    }
}

